# -*- coding: utf-8 -*-
import sys
import numpy as np
import multiprocessing
import matplotlib.pyplot as plt
from PySide import QtGui
from PySide import QtCore

def draw_sin(a, b, c):
    x = np.linspace(1, 10, 100)
    y = a * np.sin(b * x + c)

    plt.title(u'常用')
    plt.plot(x, y)
    plt.show()

class Window(QtGui.QWidget):
    def __init__(self, parent=None):
        super(Window, self).__init__()
        # y = a*sin(b*x+c)
        self.a = QtGui.QLineEdit(u'1')
        self.b = QtGui.QLineEdit(u'1')
        self.c = QtGui.QLineEdit(u'0')
        self.ok = QtGui.QPushButton(u'ok')
        self.ok.clicked.connect(self.draw)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.a)
        layout.addWidget(self.b)
        layout.addWidget(self.c)
        layout.addWidget(self.ok)
        self.setLayout(layout)

    def draw(self):
        a = int(self.a.text(), 10)
        b = int(self.b.text(), 10)
        c = int(self.c.text(), 10)

        proc = multiprocessing.Process(target=draw_sin, args=(a, b, c))
        proc.start()

        # proc = QtCore.QProcess(self)
        # proc.start([a, b, c])

if __name__ == '__main__':
    multiprocessing.freeze_support()
    app = QtGui.QApplication(sys.argv)
    widget = Window()
    widget.show()
    sys.exit(app.exec_())
